define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'god/examarea/index',
                    add_url: 'god/examarea/add',
                    edit_url: 'god/examarea/edit',
                    del_url: 'god/examarea/del',
                }
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                columns: [
                    [
                        {field: 'state', checkbox: true,},
                        {field: 'id', title: 'ID'},
                        {field: 'code', title: '考区编号'},
                        {field: 'name', title: '考区名称'},
                        {field: 'area_id', title: '地址'},
                        {
                            field: 'is_choose',
                            title: '是否可选',
                            searchList: {"normal": "是", "hidden": "否"},
                            formatter: Table.api.formatter.status
                        },
                        {
                            field: 'status',
                            title: __("Status"),
                            searchList: {"normal": __('Normal'), "hidden": __('Hidden')},
                            formatter: Table.api.formatter.status
                        },
                        {
                            field: 'create_time',
                            title: '创建时间',
                            formatter: Table.api.formatter.datetime,
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            sortable: true
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);

        },
        add: function () {
            Form.api.bindevent($("form[role=form]"));
        },
        edit: function () {
            Form.api.bindevent($("form[role=form]"));
        }
    };
    return Controller;
});
